<!----------------------------------------------------
ページ名：Club.jsp
所　　属：H3A1 04
名　　前：大瀬碩
説　　明：クラブ情報を表示するページ
------------------------------------------------------>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@page import="java.sql.*"%>
    <%@page import="java.io.*"%>
<%@page import="java.util.Properties"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="css/bootstrap.min.css" rel="stylesheet">
<title>クラブ活動情報</title>
</head>
<body>
<!-- ナビゲーションバー -->
<div class="navbar navbar-default">
  <div class="navbar-header">
    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </button>
    <a class="navbar-brand" href="index.jsp"><img alt="" src="images/logo2.png"></a>
  </div>
  <div class="navbar-collapse collapse">
    <ul class="nav navbar-nav">
      <li><a href="TimetableClassSelection.jsp">時間割情報</a></li>
      <li class="active"><a href="ClubList.jsp">部活動情報</a></li>
      <li><a href="SupplementaryClasses.jsp">振り替え補講</a></li>
      <li><a href="HolidayAttendance.jsp">土日出校申請</a></li>
      <li><a href="AttendanceHistory.jsp">出席履歴</a></li>
    </ul>
    <ul class="nav navbar-nav navbar-right">
      <li><a href="<%out.print(request.getContextPath());%>/Logout">ログアウト</a></li>
    </ul>
  </div>
</div>
	<h1 align="center">
	<%
	//クラブ名表示
	ServletContext context = this.getServletContext();
	String path = context.getRealPath("/WEB-INF/connect.properties");
	
	InputStream in = new FileInputStream(path);
	Properties properties = new Properties();
	properties.load(in);
	in.close();
	
	HttpSession sess = request.getSession(true);
	Object sel_club = sess.getAttribute("sel_club");
	Class.forName("com.mysql.jdbc.Driver");
	Connection conn = null;
	String url = properties.getProperty("key1");
	String user = properties.getProperty("key2");
	String password = properties.getProperty("key3");
	conn = DriverManager.getConnection(url, user, password);
	Statement stmt = conn.createStatement();
	String sql = "SELECT * FROM club WHERE club_id = "+sel_club;
	ResultSet rs = stmt.executeQuery(sql);
	while(rs.next()){
		out.print(rs.getString("club_name"));
	}
	rs.close();
	stmt.close();
	conn.close();
	%>
	</h1>
	<%
	//クラブ画像表示
	if("1".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/futsal.png\" style=\"height: 270px;\"></h1>");
	}
	if("2".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/baseball.png\" style=\"height: 270px;\"></h1>");
	}
	if("3".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/tennis.png\" style=\"height: 270px;\"></h1>");
	}
	if("4".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/soft_tennis.png\" style=\"height: 270px;\"></h1>");
	}
	if("5".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/badminton.png\" style=\"height: 270px;\"></h1>");
	}
	if("6".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/table_tennis.png\" style=\"height: 270px;\"></h1>");
	}
	if("7".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/programming.png\" style=\"height: 270px;\"></h1>");
	}
	if("8".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/qualification.png\" style=\"height: 270px;\"></h1>");
	}
	if("9".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/light_music.png\" style=\"height: 270px;\"></h1>");
	}
	if("10".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/cinema.png\" style=\"height: 270px;\"></h1>");
	}
	if("11".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/reading.png\" style=\"height: 270px;\"></h1>");
	}
	if("12".equals(sel_club)){
		out.print("<h1 align=\"center\"><img src=\"images/gardening.png\" style=\"height: 270px;\"></h1>");
	}
	%>
	
	<div class="container text-center">
		<div>
			<table class="table table-bordered" style="font-size: large">
				<tr>
					<td>活動時間:</td>
					<td>${ requestScope.at }</td>
				</tr>
				
				<tr>
					<td>活動場所:</td>
					<td>${ requestScope.ap }</td>
				</tr>
				
				<tr>
					<td>活動内容:</td>
					<td>${ requestScope.ac }</td>
				</tr>
				
			</table>
		</div>
		<%
		    //キャプテン、副キャプテンの場合は編集ボタンを押せるようにする
			HttpSession ses = request.getSession(true);
	    	Object club_edit = ses.getAttribute("club_edit");
	    	
	    	if ("OK".equals(club_edit)){
	    		out.println("<a class=\"btn btn-lg btn-info\" href=\"ClubEdit.jsp\"><i class=\"glyphicon glyphicon-pencil\" title=\"キャプテン・副キャプテンは編集を行うことができます\"><br>編集</i></a>");
	    	}
	    	%>
	</div>
	
	
	<br>
	<h2 align="center">連絡フォーム</h2>
	<p align="center"><font size="3">休む時等何か連絡があればこちらのフォームから！</font></p>
	<form method="post" action="ClubContact">
	<div class="form-group">
		<div align="center">
			<table>
				<tr>
					<td align="center">
						<textarea name="clubtxt" cols="47" rows="10" class="form-control"></textarea>
					</td>
				</tr>
				
				<tr><td>　</td></tr>
				
				<tr>
					<td align="center">
						<input type="submit" name="Information" class="btn btn-warning" value="送信" style="font-size: large">
					</td>
				</tr>
			</table>
		</div>
	</div>
	</form>
	

	<br>

	<div align="center">
		<%
		
		
		Object login = ses.getAttribute("login");
		
		if(login==null){
			out.print("<a href=\"ClubList.jsp\" class=\"btn btn-lg btn-danger\"><i class=\"glyphicon glyphicon-arrow-left\"><br>部活動選択へ戻る</i></a>");
		}
		%>
		<a href="index.jsp" class="btn btn-lg btn-danger"><i class="glyphicon glyphicon-home"><br>トップへ</i></a>
		<br>
		<br>
		
	</div>
</body>
</html>